package com.txzt.gaea.provide.controller;

import com.txzt.base.core.RtnInfo;
import com.txzt.gaea.common.base.controller.BaseController;
import com.txzt.gaea.common.page.PageInfoBT;
import com.txzt.gaea.provide.dto.InformationTypeInfoAddDTO;
import com.txzt.gaea.provide.dto.InformationTypeInfoUpdateDTO;
import com.txzt.gaea.provide.dto.InformationTypeQueryDTO;
import com.txzt.gaea.provide.service.InformationTypeInfoService;
import com.txzt.gaea.provide.utils.LogUtils;
import com.txzt.gaea.provide.vo.InformationTypeInfoVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@RestController
@RequestMapping("/informationType")
public class InformationTypeInfoController extends BaseController {

    @Autowired
    private InformationTypeInfoService informationTypeInfoService;

    /**
     * 查询列表
     */
    @PostMapping(value = "/list")
    public RtnInfo<PageInfoBT<InformationTypeInfoVO>> list(@RequestBody InformationTypeQueryDTO dto) throws Exception {
        LogUtils.logSave("informationType#list", "查询列表", "com.txzt.gaea.provide.controller.InformationTypeInfoController");
        return informationTypeInfoService.list(dto);
    }

    /**
     * 添加
     */
    @PostMapping(value = "/add")
    public RtnInfo add(@RequestBody InformationTypeInfoAddDTO dto) throws Exception {
        LogUtils.logSave("informationType#add", "添加", "com.txzt.gaea.provide.controller.InformationTypeInfoController");
        if (null == dto || 0 != dto.checkValid().getCode()) {
            return RtnInfo.PARAM_MISSING;
        }
        return RtnInfo.success(informationTypeInfoService.add(dto));
    }

    /**
     * 查询详情
     */
    @GetMapping(value = "/detail/{id}")
    public RtnInfo detail(@PathVariable Long id) throws Exception {
        LogUtils.logSave("informationType#detail", "查询详情", "com.txzt.gaea.provide.controller.InformationTypeInfoController");
        return informationTypeInfoService.detail(id);
    }

    /**
     * 更新
     */
    @PostMapping(value = "/update")
    public RtnInfo update(@RequestBody InformationTypeInfoUpdateDTO dto) throws Exception {
        LogUtils.logSave("informationType#update", "更新", "com.txzt.gaea.provide.controller.InformationTypeInfoController");
        if (null == dto || 0 != dto.checkValid().getCode()) {
            return RtnInfo.PARAM_MISSING;
        }
        return informationTypeInfoService.update(dto);
    }

    /**
     * 删除数据
     */
    @GetMapping(value = "/del/{id}")
    public RtnInfo del(@PathVariable Long id) throws Exception {
        LogUtils.logSave("informationType#del", "删除数据", "com.txzt.gaea.provide.controller.InformationTypeInfoController");
        return informationTypeInfoService.del(id);
    }
}
